﻿#region USING STATEMENTS
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Fusion.Content;
#endregion

#region CODE BODY
namespace Fusion.Management
{
    public static class FCanvas
    {
        //////////////////////////////////////////////////
        // Data Fields
        //////////////////////////////////////////////////
        private static Canvas Graphics;
        private static SpriteFont defFont;
        public static Color ClearColor = Color.CornflowerBlue;

        //////////////////////////////////////////////////
        // Member Properties
        //////////////////////////////////////////////////
        public static Canvas Batch
        {
            get { return Graphics; }
        }
        public static SpriteFont DefFont
        {
            get
            {
                if (defFont == null)
                    defFont = FContent.Load<SpriteFont>(@"Fonts\Default");

                return defFont;
            }
        }

        //////////////////////////////////////////////////
        // Static Methods
        //////////////////////////////////////////////////
        public static void SetCanvas(Canvas TheCanvas)
        {
            Graphics = TheCanvas;
        }
        public static void ClearCanvas()
        {
            Graphics.GraphicsDevice.Clear(ClearColor);
        }
        public static void Begin(bool Lighting = false)
        {
            if (Lighting)
                FLights.Prepare();

            Graphics.Begin();
        }
        public static void End(bool Lighting = false)
        {
            Graphics.End();

            if (Lighting)
                FLights.RenderLights();
        }
        public static void EndForm()
        {
            Graphics.End();
            FLights.RenderLights();
            Graphics.GraphicsDevice.Present();
        }

        //////////////////////////////////////////////////
        // Canvas/SpriteBatch Abstraction
        //////////////////////////////////////////////////
        public static void DrawRectangle(Rectangle ToDraw, Single Thickness, Color Overlay)
        {
            Graphics.DrawRectangle(ToDraw, Thickness, Overlay);
        }
        public static void FillRectangle(Rectangle ToFill, Color Overlay)
        {
            Graphics.FillRectangle(ToFill, Overlay);
        }
        public static void DrawLine(Vector2 PoInt32One, Vector2 PoInt32Two, Single Thickness, Color Overlay)
        {
            Graphics.DrawLine(PoInt32One, PoInt32Two, Thickness, Overlay);
        }
        
        public static void Draw(Texture2D TheTexture, Rectangle Dest, Color Overlay)
        {
            Graphics.Draw(TheTexture, Dest, Overlay);
        }
        public static void Draw(Texture2D TheTexture, Vector2 Pos, Color Overlay)
        {
            Graphics.Draw(TheTexture, Pos, Overlay);
        }
        public static void Draw(Texture2D TheTexture, Rectangle Dest, Rectangle Source, Color Overlay)
        {
            Graphics.Draw(TheTexture, Dest, Source, Overlay);
        }
        public static void Draw(Texture2D TheTexture, Vector2 Pos, Rectangle Source, Color Overlay)
        {
            Graphics.Draw(TheTexture, Pos, Source, Overlay);
        }
        public static void Draw(Texture2D TheTexture, Rectangle Dest, Rectangle Source, Color Overlay, Single Rotation, Vector2 Origin, SpriteEffects Effect, Single Depth)
        {
            Graphics.Draw(TheTexture, Dest, Source, Overlay, Rotation, Origin, Effect, Depth);
        }
        public static void Draw(Texture2D TheTexture, Vector2 Pos, Rectangle Source, Color Overlay, Single Rotation, Vector2 Origin, Single Scale, SpriteEffects Effect, Single Depth)
        {
            Graphics.Draw(TheTexture, Pos, Source, Overlay, Rotation, Origin, Scale, Effect, Depth);
        }
        public static void Draw(Texture2D TheTexture, Vector2 Pos, Rectangle Source, Color Overlay, Single Rotation, Vector2 Origin, Vector2 Scale, SpriteEffects Effect, Single Depth)
        {
            Graphics.Draw(TheTexture, Pos, Source, Overlay, Rotation, Origin, Scale, Effect, Depth);
        }

        public static void Draw(GameTexture TheTexture, Rectangle Dest, Color Overlay)
        {
            FTextures.Draw(TheTexture, Dest, Overlay);
        }
        public static void Draw(GameTexture TheTexture, Vector2 Pos, Color Overlay)
        {
            FTextures.Draw(TheTexture, Pos, Overlay);
        }
        public static void Draw(GameTexture TheTexture, Rectangle Dest, Rectangle Source, Color Overlay)
        {
            FTextures.Draw(TheTexture, Dest, Source, Overlay);
        }
        public static void Draw(GameTexture TheTexture, Vector2 Pos, Rectangle Source, Color Overlay)
        {
            FTextures.Draw(TheTexture, Pos, Source, Overlay);
        }
        public static void Draw(GameTexture TheTexture, Rectangle Dest, Rectangle Source, Color Overlay, Single Rotation, Vector2 Origin, SpriteEffects Effect, Single Depth)
        {
            FTextures.Draw(TheTexture, Dest, Source, Overlay, Rotation, Origin, Effect, Depth);
        }
        public static void Draw(GameTexture TheTexture, Vector2 Pos, Rectangle Source, Color Overlay, Single Rotation, Vector2 Origin, Single Scale, SpriteEffects Effect, Single Depth)
        {
            FTextures.Draw(TheTexture, Pos, Source, Overlay, Rotation, Origin, Scale, Effect, Depth);
        }
        public static void Draw(GameTexture TheTexture, Vector2 Pos, Rectangle Source, Color Overlay, Single Rotation, Vector2 Origin, Vector2 Scale, SpriteEffects Effect, Single Depth)
        {
            FTextures.Draw(TheTexture, Pos, Source, Overlay, Rotation, Origin, Scale, Effect, Depth);
        }

        public static void DrawString(String Text, Vector2 Pos, Color Overlay)
        {
            Graphics.DrawString(DefFont, Text, Pos, Overlay);
        }
        public static void DrawString(String Text, Vector2 Pos, Color Overlay, Single Rotation, Vector2 Origin, Single Scale, SpriteEffects Effect, Single Depth)
        {
            Graphics.DrawString(DefFont, Text, Pos, Overlay, Rotation, Origin, Scale, Effect, Depth);
        }
        public static void DrawString(String Text, Vector2 Pos, Color Overlay, Single Rotation, Vector2 Origin, Vector2 Scale, SpriteEffects Effect, Single Depth)
        {
            Graphics.DrawString(DefFont, Text, Pos, Overlay, Rotation, Origin, Scale, Effect, Depth);
        }
        public static void DrawString(String Text, Vector2 Pos, Color Overlay, Color Border)
        {
            Graphics.DrawString(DefFont, Text, new Vector2(Pos.X - 1f, Pos.Y), Border);
            Graphics.DrawString(DefFont, Text, new Vector2(Pos.X + 1f, Pos.Y), Border);
            Graphics.DrawString(DefFont, Text, new Vector2(Pos.X, Pos.Y - 1f), Border);
            Graphics.DrawString(DefFont, Text, new Vector2(Pos.X, Pos.Y + 1f), Border);

            Graphics.DrawString(DefFont, Text, Pos, Overlay);
        }
        public static void DrawString(String Text, Vector2 Pos, Color Overlay, Color Border, Single Rotation, Vector2 Origin, Single Scale, SpriteEffects Effect, Single Depth)
        {
            Graphics.DrawString(DefFont, Text, new Vector2(Pos.X - 1f, Pos.Y), Border, Rotation, Origin, Scale, Effect, Depth);
            Graphics.DrawString(DefFont, Text, new Vector2(Pos.X + 1f, Pos.Y), Border, Rotation, Origin, Scale, Effect, Depth);
            Graphics.DrawString(DefFont, Text, new Vector2(Pos.X, Pos.Y - 1f), Border, Rotation, Origin, Scale, Effect, Depth);
            Graphics.DrawString(DefFont, Text, new Vector2(Pos.X, Pos.Y + 1f), Border, Rotation, Origin, Scale, Effect, Depth);

            Graphics.DrawString(DefFont, Text, Pos, Overlay, Rotation, Origin, Scale, Effect, Depth);
        }
        public static void DrawString(String Text, Vector2 Pos, Color Overlay, Color Border, Single Rotation, Vector2 Origin, Vector2 Scale, SpriteEffects Effect, Single Depth)
        {
            Graphics.DrawString(DefFont, Text, new Vector2(Pos.X - 1f, Pos.Y), Border, Rotation, Origin, Scale, Effect, Depth);
            Graphics.DrawString(DefFont, Text, new Vector2(Pos.X + 1f, Pos.Y), Border, Rotation, Origin, Scale, Effect, Depth);
            Graphics.DrawString(DefFont, Text, new Vector2(Pos.X, Pos.Y - 1f), Border, Rotation, Origin, Scale, Effect, Depth);
            Graphics.DrawString(DefFont, Text, new Vector2(Pos.X, Pos.Y + 1f), Border, Rotation, Origin, Scale, Effect, Depth);

            Graphics.DrawString(DefFont, Text, Pos, Overlay, Rotation, Origin, Scale, Effect, Depth);
        }
    }
}
#endregion

//////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2012 Jeffery Thomas Sventora
//////////////////////////////////////////////////////////////////////////////////////////////